﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
using System.Diagnostics;

namespace 不动产证管理系统wpf
{


    #region mysql帮助类
   public  class  Mysqlhelp
    {
        
        public static string mConnectdbPath = $"{ConfigurationManager.ConnectionStrings["conn"].ConnectionString}";//读取不动产证管理系统wpf.dll.config里的文本数据 地址,用户名和密码
        public static MySqlConnection? mySqlConnection { get; set; }

        public   Mysqlhelp()
        {
            Task.Run(() =>
            {
                try
                {
                    if (mySqlConnection == null)
                    {
                        Debug.Print($"连接地址是：{mConnectdbPath}");
                        mySqlConnection = new MySqlConnection(mConnectdbPath);
                        mySqlConnection.Open();
                        Debug.Print("连接数据库成功");                      

                    }
                }
                catch (Exception)
                {
                    Debug.Print("连接数据库失败");

                }
                
            });


        }


    }
    #endregion

    public static class Mysqlhelp1
    {
        public static string mConnectdbPath = $"{ConfigurationManager.ConnectionStrings["conn"].ConnectionString}";
        public static MySqlConnection? mySqlConnection 
        {         
            get; set; 
        }   
    }


}
